package com.itlong.cloud.controller;

import com.itlong.cloud.POJO.VO.MessageVO;
import com.itlong.cloud.enumerate.ecode.BaseErrorCodeEnum;
import com.itlong.cloud.project.smartcard.ISmartCardPropertyValueServiceClient;
import com.itlong.cloud.thrown.DataAccessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <desc>
 *      物业增值一卡通
 * </desc>
 *
 * @createDate 2019/06/12
 */
@RestController
@RequestMapping("/smartCard/syncdata/propertyvalue")
public class SmartCardPropertyValueController {

    @Autowired
    ISmartCardPropertyValueServiceClient iSmartCardPropertyValueServiceClient;

    /**
     * <desc>
     *      同步楼栋单元房间信息
     * <desc/>
     *
     * @param json json
     * @return
     * @author Jiaqi.X
     * @createDate 2019/03/29
     */
    @RequestMapping(value = "project/getBuildAndUnitAndRoomInfo",
            method = RequestMethod.POST ,produces = "application/json")
    @ResponseBody
    public MessageVO getBuildAndUnitAndRoomInfo(@RequestBody String json) {
        try {
            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                    iSmartCardPropertyValueServiceClient.getBuildAndUnitAndRoomInfo(json));
        }catch (Exception e){
            throw  new DataAccessException("【旺龙一卡通对接_同步楼栋单元房间信息】getBuildAndUnitAndRoomInfo同步失败 " , e);
        }
    }



    /**
     * <desc>
     *      提交房间与软卡号绑定信息
     * <desc/>
     *
     * @param json 提交数据
     * @return
     * @author Jiaqi.X
     * @createDate 2019/03/29
     */
    @RequestMapping(value = "project/syncSoftCardNo",
            method = RequestMethod.POST ,produces = "application/json")
    @ResponseBody
    public MessageVO syncSoftCardNo(@RequestBody String json) {
        try {
            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                    iSmartCardPropertyValueServiceClient.saveSoftCardNo(json));
        }catch (Exception e){
            throw  new DataAccessException("【旺龙一卡通对接_提交房间与软卡号绑定信息】提交房间与软卡号绑定信息失败 " , e);
        }
    }
}
